#include <iostream>
#include <vector>
#include <pthread.h>
#include <unistd.h>
__thread int g_val = 100;
void *handler2(void *args)
{
    int cnt = 5;
    char *name = static_cast<char *>(args);

    while (cnt--)
    {
        sleep(1);
        printf("threadname:%s, &g_val:%p,g_val:%d \n",name, &g_val, g_val);
    }
    return nullptr;
}
void *handler1(void *args)
{
    int cnt = 5;
    char *name = static_cast<char *>(args);
    while (cnt--)
    {
        sleep(1);
        g_val++;
        printf("threadname:%s, &g_val:%p,g_val:%d \n",name, &g_val, g_val);
    }

    return nullptr;
}

void *handler(void *args)
{
    int cnt = 5;
    char *name = static_cast<char *>(args);
    printf("name: %s,cnt:%d \n:&cnt: %p", name, cnt, &cnt);
    return nullptr;
}
int main()
{
    pthread_t tid1;
    pthread_t tid2;

    pthread_create(&tid1, nullptr, handler1, (void *)"thread_1");
    pthread_create(&tid2, nullptr, handler2, (void *)"thread_2");

    void *res;
    pthread_join(tid1, &res);
    pthread_join(tid2, &res);
}